package com.example.javawebserver.demos.web.controller;

import com.example.javawebserver.demos.web.model.FundModel;
import com.example.javawebserver.demos.web.service.ProfitabilityAnalysisService;
import com.example.javawebserver.demos.web.utils.JsonData;
import com.example.javawebserver.demos.web.vo.SelectVo;
import com.example.javawebserver.pojo.DeletePojo;
import com.example.javawebserver.pojo.SelectPojo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/ProfitabilityAnalysis")
@CrossOrigin(origins = "http://localhost:8080")//解决跨域问题
@Slf4j
public class ProfitabilityAnalysisController {

    @Autowired
    private ProfitabilityAnalysisService profitabilityAnalysisService;


    @PostMapping("/select")
    public JsonData select(@RequestBody SelectPojo selectPojo){
        log.info("传入的id为：" + selectPojo.getId());
        return profitabilityAnalysisService.select(selectPojo.getId());
    }

    @PostMapping("/insert")
    public JsonData insert(@RequestBody FundModel fundModel){
        log.info("传入的新增主体值为:" + fundModel);
        return profitabilityAnalysisService.insert(fundModel);
    }

    @PostMapping("/update")
    public JsonData update(@RequestBody FundModel fundModel,int id){
        log.info("传入的修改主体值为:" + fundModel);
        return profitabilityAnalysisService.update(fundModel,id);
    }

    @PostMapping("/delete")
    public JsonData delete(@RequestBody DeletePojo deletePojo){
        log.info("传入的参数为:" + deletePojo.getId());
        return profitabilityAnalysisService.delete(deletePojo);
    }

    @PostMapping("/selectAll")
    public JsonData selectAll(){
        return profitabilityAnalysisService.selectAll();
    }

}
